home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13877 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  37 lines

  1. Newsgroups: comp.lang.c++
  2. Path: news.duc.auburn.edu!mallard!greerjo
  3. From: greerjo@mail.auburn.edu (John M. Greer)
  4. Subject: Why does this work?
  5. Message-ID: <DoxvnA.L0C@mail.auburn.edu>
  6. Sender: usenet@mail.auburn.edu (Usenet Administrator)
  7. Nntp-Posting-Host: mallard2.duc.auburn.edu
  8. Organization: Auburn University
  9. X-Newsreader: TIN [version 1.2 PL2]
  10. Date: Wed, 27 Mar 1996 18:35:33 GMT
  11.  
  12. This is probably a horribly simple question, but I was going through a 
  13. few books, brushing up on my iostreams, when I saw this tidbit in Jamsa's 
  14. Multimedia Trilogy (The CD-ROM by Kris Jamsa)
  15.  
  16. #include <iostream.h>
  17. #include <ctype.h>
  18.  
  19. void main(void)
  20.  {
  21.    char letter;
  22.  
  23.    while (! cin.eof())
  24.      {
  25.        letter = cin.get();
  26.        letter = toupper(letter);
  27.        cout << letter;
  28.      }
  29.  }
  30.  
  31. Why does this work!?!?  It seems to reserve storage for only one 
  32. character in letter, but outputs a whole line at a time.  Feel free to 
  33. flame my stupidity, but please satisfy my curiosity (I'm really not this 
  34. clueless, I promise!!)
  35.  
  36. John Greer
  37.